"""
@name : 6.多进程-进程锁-Lock
@author : wenyao
@projectname: sanchuanglianxi
"""
from multiprocessing import Process,Manager
from multiprocessing import RLock

def func(lock,i,lst):
    with lock:
        print(i)
        lst[0] += 100
        print(lst)

if __name__ == "__main__":
    mange = Manager()
    p_lst = []
    lst = mange.list([1,2])
    lock = RLock()
    for i in range(10):
        p = Process(target=func, args = (lock,i, lst))
        p.start()
        p_lst.append(p)

    [p.join() for p in p_lst]
